<!-- 容器类型管理 - 综合表单页面 -->
<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="SuperTablePage" @selection-change="e => selection = e">
    </ex_super_table_page>
    <ex_super_dialog_form ref="formDialog"  v-bind="dialog"
      @afterSubmitSuccess="$refs['SuperTablePage'].reload()">

    </ex_super_dialog_form>

    <dialog_detail_container ref="dialog_detail_container" />
    <print_sku ref="print_sku" itemKey="id" businessType="CONTAINER"/>


  </div>
</template>
<script>

import print_sku from '@/component/print/print_sku'


import superTablePageFunction from '@/mixin/super-table-page-function';
import dialog_detail_container from './dialog/dialog_detail_container.vue'
export default {
  title: 'title_container_manage',
  mixins: [superTablePageFunction],
  components: {  print_sku,dialog_detail_container },
  data() {
    return {
      selection: [],
      option: {
        search: {
          model: [
            { label: "label_container_code", key: "code", type: 'input', },
            {
              label: "label_status", key: "status", type: 'select',
              enum: 'BaseContainerStatusEnum',
            },
            {
              label: "label_start_time",
              key: "createDateStart",
              fold: true,
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
            {
              label: "label_end_time",
              key: "createDateEnd",
              fold: true,
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
          ],
        },
        actionExtra: [
          {
            label: 'label_print_barcode', attrs: { type: "primary" }, click: (row) => {
              if (_.isEmpty(this.selection)) {
                return this.$message.error(this.$tt('tip_please_select_order'))
              }
              this.print(this.selection)
            }
          },
        ],

        table: {
          url: "/wms-api/base/WmsBaseContainerRpc/selectPage.json",
          attrs: {},
          model: [
            { type: 'selection', clickToggle: true, keyGroup: 'label_table_operate' },

            {
              key: 'code', label: 'label_container_code', 'min-width': 220,
              render: (h, { row, column }) => {
                const code = row[column.property]
                if (!code) return this.$tt('data_temp_none')
                return (<text_extra_tooltip_operate
                  value={code}  extra_barcode_image extra_text_align='center'
                  data_type={column.property} data_id={row.id}
                />)
              },

            },
            { key: 'status', label: 'label_status', formatter: (r, c, v, i) => this.$enumShow(v, "BaseContainerStatusEnum"), },
            { key: 'containerTypeCode', label: 'label_container_type_code', },
            { key: 'warehouseCode', label: 'label_warehouse_code', },
            { key: 'areaCode', label: 'label_warehouse_area_code', },
            { key: 'locationCode', label: 'label_warehouse_location_code', },
            { key: 'compartmentNum', label: 'label_grid_mouth_count', },
            { key: 'gmtCreate', label: 'label_create_time', 'min-width': 120, 'show-overflow-tooltip': true, formatter: (r, c, v, i) => this.$dateFormat(v) },
            {
              type: 'operate', width: 210, operate: [
                {
                  label: 'label_edit', auth: 'wms_container_edit', click: (row) => {
                    // this.dialogTitle = this.$tt('label_edit_container')
                    this['$refs']['formDialog'].showNew({
                      title:this.$tt('label_edit_container'),
                      params:{ "id": row["id"] },
                    })
                  }
                },
                {
                  type: 'more',
                  items: [
                    { label: "label_print_barcode", click: (row) => this.print([row]) },

                    { label: 'label_view_detail', click: (row) => this.clickDetail(row) },

                  ]
                },
                {
                  label: 'label_delete', auth: 'wms_container_delete', type: "confirm-button", url: '/wms-api/base/WmsBaseContainerRpc/remove.json', message: 'text_confirm_sure_delete',
                  buttonClass: "button_text_danger", confirmButtonType: 'danger',
                  params: (row) => { return { "id": row["id"] } }, done: ['reload', 'tip']
                },
              ]
            },
          ],

        }
        ,

      },

      dialog: {
        customClass: 'dialog_auto',
        submitUrl: '/wms-api/base/WmsBaseContainerRpc/saveUpdate.json',
        detailUrl: '/wms-api/base/WmsBaseContainerRpc/detail.json',
        form: {
          itemClass: "form_item_default", inputClass: "form_input_default",
          model: [
            { key: 'code', label: 'label_container_code', disabled: true },
            { key: 'containerTypeCode', label: 'label_container_type_code', disabled: true },
            // {
            //   key: 'assignUserIds', label: 'label_assign_user', type: "common_user_select", multiple:true,
            // },
            { key: 'compartmentNum', label: 'label_grid_mouth_count', },
            { key: 'containerRow', label: 'label_container_Layout_row_count', },
            { key: 'containerColumn', label: 'label_container_Layout_col_count', },
          ],
          rules: {
            'code': { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
            'containerTypeId': { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
          },
        }
      },
    };
  },
  methods: {
    print(rows) {
      this.$refs.print_sku.show(rows)
    },
    clickDetail(row) {
      let title = this.$formatNameCode(this.$tt('label_container_detail'), row.code)
      this.$refs['dialog_detail_container'].show({ params: { id: row.id }, title })
    },
  }
};

</script>
<style></style>
